<?php


namespace App\Http\service;


use App\Engine\BaseModel;
use App\Exceptions\ApiException;
use App\Models\Active;
use App\Models\Appointment;
use App\Models\AroundEnvironment;
use App\Models\Article;
use App\Models\ArticleCate;
use App\Models\Banner;
use App\Models\BindGood;
use App\Models\BindInvite;
use App\Models\ChickenRank;
use App\Models\Custom;
use App\Models\EggLog;
use App\Models\Feed;
use App\Models\Floor;
use App\Models\Goods;
use App\Models\GoodsOrder;
use App\Models\HomeSet;
use App\Models\House;
use App\Models\ImageBanners;
use App\Models\Manage;
use App\Models\MarkingForm;
use App\Models\Nav;
use App\Models\Notice;
use App\Models\PlayBanners;
use App\Models\Property;
use App\Models\Sys;
use App\Models\TreeLog;
use App\Models\TurntableActive;
use App\Models\TurntableLog;
use App\Models\TxLog;
use App\Models\Type;
use App\Models\User;
use App\Models\UserBindGoods;

class ModelService
{
    private $model;
    private $TableName;
    private $with=[];
    public function __construct($table)
    {
        $this->TableName=$table;
        switch ($table){
            case "manages"://管理员
               $this->model=new Manage();
               break;
            case "properties"://楼栋
                $this->model=new Property();
                break;
            case "types"://房屋类型
                $this->model=new Type();
                break;
            case "floors"://楼层
                $this->model=new Floor();
                break;
            case "actives"://活动
                $this->model=new Active();
                break;
            case "users"://用户
                $this->model=new User();
                $this->with=$this->model->with;
                break;
            case "customs"://顾问
                $this->model=new Custom();
                break;
            case "appointments"://预约
                $this->model=new Appointment();
                $this->with=$this->model->with;
                break;
            case "houses"://房屋
                $this->model=new House();
                $this->with=$this->model->with;
                break;
            case "home_sets"://首页设计
                $this->model=new HomeSet();
                break;
            case "turntable_actives"://大转盘
                $this->model=new TurntableActive();
                break;
            case "around_environment"://周边环境
                $this->model=new AroundEnvironment();
                break;
            case "chicken_ranks"://小鸡等级
                $this->model=new ChickenRank();
                break;
            case "feeds"://饲料表
                $this->model=new Feed();
                break;
            case "sys"://系统配置
                $this->model=new Sys();
                break;
            case "egg_logs":
                $this->model=new EggLog();
                break;
            case "turntable_logs":
                $this->model=new TurntableLog();
                break;
            case "articles":
                $this->model=new Article();
                break;
            case "banners":
                $this->model=new Banner();
                break;
            case "navs":
                $this->model=new Nav();
                break;
            case "tx_log":
                $this->model=new TxLog();
                break;
            case "tree_logs":
                $this->model=new TreeLog();
                break;
            case "bind_invite":
                $this->model=new BindInvite();
                break;
            case "bind_goods":
                $this->model=new BindGood();
                break;
            case "user_bind_goods":
                $this->model=new UserBindGoods();
                break;
            case "goods":
                $this->model=new Goods();
                break;
            case "goods_order":
                $this->model=new GoodsOrder();
                $this->with=$this->model->with;
                break;
            case "notice":
                $this->model=new Notice();
                break;
            case "play_banners":
                $this->model=new PlayBanners();
                break;
            case "article_cate":
                $this->model=new ArticleCate();
                break;
            case "image_banners":
                $this->model=new ImageBanners();
                break;
            case "marketing_form":
                $this->model=new MarkingForm();
                break;
            default:
                throw new ApiException("操作错误");
        }
    }

    public function getWith()
    {
        return $this->with;
    }

    public function getModel():BaseModel
    {
        return $this->model;
    }
}
